const query = require('../sqlUtil/connect.js')
const types = ['A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z']
module.exports = {
    //所有的期货名称前缀类型
    types : types
    ,
    //通过期货的名称前缀类型查找对应的期货的数组
    async queryQihuoName(type){
        return query.runSql(`select id,qihuoName from qihuo_table where type=\'${type}\'`)
    },
    //通过期货的名称查找对应的详细的期货数组
    async getDetailByQihuo(qihuo){
        return query.runSql(`select * from detal_table where qihuo=\'${qihuo}\'`)
    },
    //通过期货的Id查找对应详细的期货名称数组
    async getDetailById(id){
        return query.runSql(`select detalName from detal_table where qihuoId=\'${id}\'`)
    },
    //插入一条新的记录,记录期货的期货公司名称,发起人的用户名,密码,还有记录时间
    async uploadRecord(detailQihuo,username,password){
        return query.insertSql('insert into records_table values(null,?,?,?,CURRENT_TIMESTAMP())',[detailQihuo,username,password])
    },
    //插入一条新的记录,记录发起人的用户名,密码,还有记录时间,模拟的数据!!
    async uploadSimRecord(username,password){
        return query.insertSql('insert into simrecords_table values(null,?,?,CURRENT_TIMESTAMP())',[username,password])
    }
}